package com.example.demo.server3.template;

import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;

public class CMPP_SUBMIT implements ProtocolTemplate{
    private MessageHeader messageHeader;
    private long Msg_Id;
    private byte Pk_total;
    private byte Pk_number;
    private byte Registered_Delivery;
    private byte Msg_level;
    private String Service_Id;
    private byte Fee_UserType;
    private String Fee_terminal_Id;
    private byte TP_pId;
    private byte TP_udhi;
    private byte Msg_Fmt;
    private String Msg_src;
    private String FeeType;
    private String FeeCode;
    private String ValId_Time;
    private String At_Time;
    private String Src_Id;
    private byte DestUsr_tl;
    private String Dest_terminal_Id;
    private byte Msg_Length;
    private String Msg_Content;
    private String Reserve;

    @Override
    public void structure(ByteBuf buf) {
        Msg_Id = buf.getLong(8);
        Pk_total = buf.getByte(20);
        Pk_number = buf.getByte(21);
        Registered_Delivery = buf.getByte(22);
        Msg_level = buf.getByte(23);
        Service_Id = buf.toString(24,10,CharsetUtil.US_ASCII);
        Fee_UserType = buf.getByte(34);
        Fee_terminal_Id = buf.toString(35,21,CharsetUtil.US_ASCII);
        TP_pId = buf.getByte(56);
        TP_udhi = buf.getByte(57);
        Msg_Fmt = buf.getByte(58);
        Msg_src = buf.toString(59,6,CharsetUtil.US_ASCII);
        FeeType = buf.toString(65,2,CharsetUtil.US_ASCII);
        FeeCode = buf.toString(67,6,CharsetUtil.US_ASCII);
        ValId_Time = buf.toString(73,17,CharsetUtil.US_ASCII);
        At_Time = buf.toString(90,17,CharsetUtil.US_ASCII);
        Src_Id = buf.toString(107,21,CharsetUtil.US_ASCII);
        DestUsr_tl = buf.getByte(128);
        Dest_terminal_Id = buf.toString(129,21,CharsetUtil.US_ASCII);
        Msg_Length = buf.getByte(150);
        Msg_Content = buf.toString(151,buf.capacity()-150-8,CharsetUtil.US_ASCII);
        Reserve = buf.toString(buf.capacity()-8,8,CharsetUtil.US_ASCII);
    }

    @Override
    public ByteBuf destruct() {
        return null;
    }

    public MessageHeader getMessageHeader() {
        return messageHeader;
    }

    public void setMessageHeader(MessageHeader messageHeader) {
        this.messageHeader = messageHeader;
    }
}
